<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * @method static create(array $validated)
 * @method static find($pd_id)
 */
class PostDetail extends Model
{
    use HasFactory;
    protected $table = "tb_post_detail";
    protected $primaryKey = "pd_id";
    public const CREATED_AT = "pd_create_time";
    public const UPDATED_AT = "pd_update_time";
    protected $fillable = [
      "pd_content_raw", "pd_content",
      "pd_is_reward", "pd_is_comment",
      "pd_pwd"
    ];
    // 更新当前模型时去更新关联模型的时间戳。
    protected $touches = ["post"];

    public function post(): BelongsTo
    {
        return $this->belongsTo("App\Models\Post", "post_id", "post_id");
    }

}
